import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Scanner;

public class FileEncryptor {
    public static void encryptFile(String inputFileName, String outputFileName) throws IOException {
        try (FileInputStream in = new FileInputStream(inputFileName);
             FileOutputStream out = new FileOutputStream(outputFileName)) {
            int byteRead;
            while ((byteRead = in.read()) != -1) {
                out.write((byteRead + 5) % 256);
            }
        }
    }

    public static void displayDecryptedContent(String fileName) throws IOException {
        try (FileInputStream in = new FileInputStream(fileName)) {
            int byteRead;
            while ((byteRead = in.read()) != -1) {
                int decryptedByte = (byteRead - 5 + 256) % 256;
                System.out.print((char) decryptedByte);
            }
        }
    }
    public static void main(String[] args) throws IOException {
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入源文件名: ");
        String sourceFile = scanner.nextLine();
        System.out.print("请输入加密文件名: ");
        String encryptedFile = scanner.nextLine();

        encryptFile(sourceFile, encryptedFile);
        displayDecryptedContent(encryptedFile);
    }
}